package com.example.productconsumer.controller;

import com.example.productconsumer.service.ProductRemote;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName ProductController
 * @Description TODO
 * @Author yaozhaobao
 * @Date 2020/12/6 14:51
 * @Version 1.0
 **/
@RestController
public class ProductController {

    @Resource
    ProductRemote productRemote;



    @RequestMapping(value = "/productbyid",method = RequestMethod.GET)
    public String getProductionById(@RequestParam("id")String id){

        return productRemote.getProductionById(id);
    }




    @RequestMapping(value = "/add",method = RequestMethod.GET)
    public String add(@RequestParam("name")String name,@RequestParam("price")String price){

        return productRemote.add(name,Integer.parseInt(price));
    }

    @RequestMapping(value = "/add2",method = RequestMethod.GET)
    public String add2(@RequestParam("name")String name,@RequestParam("price")String price){
        Map<String,String> map =new HashMap<String,String>();
        map.put("name",name);
        map.put("price",price);

        return productRemote.add2(map);
    }



}
